|
|
|
|
|
|
|
control, also commonly known as a command button (or simply a button), to cause something to happen. You can add a command button to a form just like you add other controlsby using the mouse to draw it. |
|
|
|
|
|
|
|
|
Like labels, command buttons have a Caption property that enables you to determine what text will appear on the button's face, so the user will know what the button does. |
|
|
|
|
|
|
|
|
To complete the interface of the Loan Calculator program, add two command buttons near the bottom of the form. Set their Name and Caption properties according to Table 2.2. Figure 2.16 shows the completed Loan Calculator interface. |
|
|
|
|
| Table 2.2 Name and Caption Properties for the Loan Calculator Program's CommandButton Controls | | Name Property | Caption Property | | cmdCalculate | Calculate Payment | | cmdExit | Exit |
|
|
|
|
|
|
Figure 2.16
After you have added the
CommandButton controls, the Loan
Calculator's interface is complete. |
|
|
|
|
|
|
|
|
Changing a Form's Properties |
|
|
|
|
|
|
|
|
Just as you define a control's appearance and behavior by setting its properties, you can also set a form's properties to govern its appearance and behavior. |
|
|
|
|
|
|
|
|
Just like controls, forms have a Name property. The default name for a project's first form is Form1; subsequently added forms are named Form2, Form3, and so on. As with controls, it's a good idea to give forms a more descriptive name. Use the Properties window to change the Name property of the Loan Calculator project's one and only form to frmMain. |
|
|
|
|
|
|
|
|
Follow these steps to change the form's Width property: |
|
|
|
|
|
|
|
|
1. Click an empty area of the form to deselect any control(s) that may be selected. This has the effect of selecting the form itself. Note that the form's name appears in the Properties window's Object box. |
|
|
|
|
|
|
|
|
2. Now that the form itself is selected, the properties presented in the Properties window are the form's properties. Scroll the Properties window until you find the Width property near the bottom of the list and note its value. |
|
|
|
|
|